﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Entities;
using DAL;

namespace SurveyGUI
{
    public partial class UpdateQuestionForm : Form
    {
        IQuestionRepository rep = new QuestionRepository();

        string ID;
        string MoTaCauHoi;
        public UpdateQuestionForm()
        {
            InitializeComponent();
        }

        public UpdateQuestionForm(string id,string mota):this()
        {
            this.ID = id;
            this.MoTaCauHoi = mota;
            txtID.Text = id;
            txtSuaCauHoi.Text = MoTaCauHoi;
        }

        private void btnHuy_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtSuaCauHoi.Text != "" && txtID.Text!="")
            {
                int stt = int.Parse(txtID.Text);
                string mota = txtSuaCauHoi.Text;
                Question q = rep.GetById(stt);

                
       
                q.MoTa = txtSuaCauHoi.Text;
                rep.UpdateQuestion(q,stt,mota); 
          
                this.Close();
            }
            else
            {
                MessageBox.Show("Bạn chưa chọn câu hỏi hãy nhấn Cancel và chọn lại:");
            }
        }

        private void txtID_TextChanged(object sender, EventArgs e)
        {

        }

        private void labelX2_Click(object sender, EventArgs e)
        {

        }

        private void labelX1_Click(object sender, EventArgs e)
        {

        }

        private void txtSuaCauHoi_TextChanged(object sender, EventArgs e)
        {

        }

        private void groupPanel1_Click(object sender, EventArgs e)
        {

        }

    }
}
